﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CMWVS.Core.Mono
{
    internal static class ReadRegistryKey
    {
        internal static RegistryKey Read(RegistryHive registryHive, string productPath)
        {
            if (Environment.Is64BitOperatingSystem == true)
            {
                RegistryKey key64 = RegistryKey.OpenBaseKey(registryHive, RegistryView.Registry64);
                if (null != key64)
                {
                    RegistryKey product64Key = key64.OpenSubKey(productPath);
                    if (null != product64Key)
                    {
                        return product64Key;
                    }
                }
            }

            RegistryKey key32Bit = RegistryKey.OpenBaseKey(registryHive, RegistryView.Registry32);
            if (null != key32Bit)
            {
                return key32Bit.OpenSubKey(productPath);
            }

            return null;
        }
    }
}